﻿namespace SerializationPerformance
{
    using System;

    public static class RandomTextGenerator
    {
        private static readonly Random Random = new Random((int)DateTime.Now.Ticks - 42);

        public static string Text(int minLength, int maxLength)
        {
            var length = RandomNumberGenerator.Number(minLength, maxLength);
            var text = new char[length];

            for (var i = 0; i < length; i++)
            {
                text[i] = (char)Random.Next(97, 122);
            }

            return new string(text);
        }

        public static string CapitalisedText(int minLength, int maxLength)
        {
            var length = RandomNumberGenerator.Number(minLength, maxLength);
            var text = new char[length];

            for (var i = 0; i < length; i++)
            {
                if (i == 0)
                    text[i] = (char)Random.Next(65, 90);
                else text[i] = (char)Random.Next(97, 122);
            }

            return new string(text);
        }

        public static string Name(int minLength, int maxLength)
        {
            var count = RandomNumberGenerator.Number(1, 3);

            var name = string.Empty;
            for (var i = 0; i < count; i++)
            {
                if (i != 0)
                    name += "-";

                name += CapitalisedText(minLength, maxLength);
            }

            return name;
        }

        public static string Description(int minLength, int maxLength)
        {
            var count = RandomNumberGenerator.Number(minLength, maxLength);

            var description = string.Empty;
            for (var i = 0; i < count; i++)
            {
                if (i == 0)
                    description += CapitalisedText(4, 8);
                else
                {
                    description += " " + Text(4, 8);
                }
            }

            return description;
        }
    }
}